package org.example.project

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@Composable
fun App2() {
    var state by remember { mutableStateOf(false) }
    DisposableEffect(Unit) {
        onDispose {
            println("hmlog--> 释放")
        }
    }
    LaunchedEffect(state) {
        if (state) {
            println("hmlog--> 打开状态")
        } else {
            println("hmlog--> 关闭状态")
        }
    }
    Column(modifier = Modifier.fillMaxSize().padding(30.dp)) {
        Button(onClick = { state = true }) {
            Text("open")
        }
        Spacer(modifier = Modifier.padding(10.dp))
        Button(onClick = { state = false }) {
            Text("close")
        }
    }
}

@Composable
fun Item(s: String) {
    println("s: $s")
    Text(s)
}

fun generateFakeListItems() = (0..100).map { "Item $it" }